#include <iostream>
using namespace std;
class Solution {
public:
    int minimumPossibleSum(int n, int target) {
        const int mod = 1e9+7;
        long long m = target / 2;
        if(n <= m) {
            return ((long long) (1+n) * n / 2) % mod;
        }else {
            return ((long long) ((1+m) * m / 2 +(long long) (target + target + (n-m)-1)*(n-m)/2)) % mod;
        }
    }
};